local tiaohe = fk.CreateSkill {
  name = "lingling__tiaohe",
}

Fk:loadTranslationTable {
  ["lingling__tiaohe"] = "调和",
  [":lingling__tiaohe"] = "出牌阶段限一次，你可以选择两名手牌数不同的其他角色，令手牌更多的一方交给另一方一张牌，若双方手牌数相同，你摸一张牌。",

  ["#lingling__tiaohe"] = "调和：选择两名角色，手牌多的角色交给对方一张手牌",
  ["#lingling__tiaohe-give"] = "调和：请将一张手牌交给 %dest",
}

tiaohe:addEffect("active", {
  anim_type = "control",
  prompt = "#lingling__tiaohe",
  card_num = 0,
  target_num = 2,
  can_use = function(self, player)
    return player:usedSkillTimes(tiaohe.name, Player.HistoryPhase) == 0
  end,
  card_filter = Util.FalseFunc,
  target_filter = function(self, player, to_select, selected)
    if #selected > 1 or to_select == player then return end
    if #selected == 0 then
      return true
    elseif #selected == 1 then
      return to_select:getHandcardNum() ~= selected[1]:getHandcardNum()
    end
  end,
  on_use = function(self, room, effect)
    local from, to = effect.tos[1], effect.tos[2]
    local player = effect.from
    if from:getHandcardNum() > to:getHandcardNum() then
      from, to = to, from
    end
    local card = room:askToCards(to, {
      min_num = 1,
      max_num = 1,
      include_equip = false,
      skill_name = tiaohe.name,
      cancelable = false,
      prompt = "#lingling__tiaohe-give::" .. from.id
    })
    room:obtainCard(from, card, true, fk.ReasonGive, to, tiaohe.name)
    if to.dead or from.dead or player.dead then return end
    if from:getHandcardNum() == to:getHandcardNum() then
      player:drawCards(1, tiaohe.name)
    end
  end,
})

return tiaohe
